import request from '@/utils/request'
import request2,{getdata} from '@/utils/seleRequest'




export function queryTotal () {
  let select= 'srvjk_cnt_home_total_select'
  return request2({
      url: `/${select}?${select}`,
      method: 'post',
      data:getdata(select)
  })
}

export function queryCountGroupByMonth (data) {
  let select= 'srvjk_cnt_pub_role_select'
  let condition = [{
    "colName": "role_name",
    "ruleType": "in",
    "value": data.type
  },{
    "colName": "release_date",
    "ruleType": "lt",
    "value": data.endTime
  },{
    "colName": "release_date",
    "ruleType": "ge",
    "value": data.startTime
  }]
  return request2({
    url: `/${select}?${select}`,
    method: 'post',
    data:getdata(select,condition)
})
}

export function queryCountGroupByPublisher (data) {
  return request({
      url: '/api/server/homePage/queryCountGroupByPublisher',
      method: 'post',
      data
  })
}

export function getStatisForCity (data) {
  let select= 'srvjk_cnt_pub_area_select'
  let condition =[{
    "colName": "release_date",
    "ruleType": "lt",
    "value": data.endDate
  },{
    "colName": "release_date",
    "ruleType": "ge",
    "value": data.startDate
  }]
  return request2({
    url: `/${select}?${select}`,
    method: 'post',
    data:getdata(select,condition)
})
}

export function getStatisForJigou (data) {
  let select= 'srvjk_cnt_pub_organ_select'
  let condition = [{
    "colName": "release_date",
    "ruleType": "lt",
    "value": data.endDate
  },{
    "colName": "release_date",
    "ruleType": "ge",
    "value": data.startDate
  }]
  return request2({
      url: `/${select}?${select}`,
      method: 'post',
      data:getdata(select,condition)
  })
}

export function getStatisForZhuanjia (data) {
  let select= 'srvjk_cnt_pub_expert_select'
  let condition = [{
    "colName": "release_date",
    "ruleType": "lt",
    "value": data.endDate
  },{
    "colName": "release_date",
    "ruleType": "ge",
    "value": data.startDate
  }]
  return request2({
      url: `/${select}?${select}`,
      method: 'post',
      data:getdata(select,condition)
  })
}

export function getStatisForLanmu (data) {
  let select= 'srvjk_cnt_pub_classify_select'
  let body = {
      "serviceName": "srvjk_cnt_pub_classify_select",
      "colNames": [
          "*"
      ],
      "group": [
          {
              "colName": "uid",
              "type": "by"
          },
          {
            "colName": "p_uid",
            "type": "by"
        },
          {
              "colName": "classify_name",
              "type": "by"
          },
          {
              "colName": "path",
              "type": "by"
          },
          {
              "colName": "path_name",
              "type": "by"
          },
          {
              "colName": "view_amount",
              "type": "sum"
          },
          {
              "colName": "pub_amount",
              "type": "sum"
          },
          {
              "colName": "collect_amount",
              "type": "sum"
          }
      ],
      "condition": [
          {
              "colName": "calendar_date",
              "ruleType": "lt",
              "value": data.endDate
          },
          {
              "colName": "calendar_date",
              "ruleType": "ge",
              "value": data.startDate
          }
      ]
  } 
  return request2({
      url: `/${select}?${select}`,
      method: 'post',
      data:body
  })
}


export function getStatisForfile (data) {
  let select= 'srvjk_cnt_pub_file_format_select'
  let body = {
      "serviceName": "srvjk_cnt_pub_file_format_select",
      "colNames": [
          "*"
      ],
      "group": 
      [
            {
                "colName": "file_format",
                "type": "by"
            },
            {
                "colName": "file_format_cnt",
                "type": "sum"
            },
            {
                "colName": "file_download_cnt",
                "type": "sum"
            }
      ],
      "condition": [
          {
              "colName": "calendar_date",
              "ruleType": "lt",
              "value": data.endDate
          },
          {
              "colName": "calendar_date",
              "ruleType": "ge",
              "value": data.startDate
          }
      ]
  } 
  return request2({
      url: `/${select}?${select}`,
      method: 'post',
      data:body
  })
}